<template>
  <div>
    <!-- 费用减免审批==> 违约金减免  || 应收减免 -->
    <!--   :pagination="pagination"
      @change="handleTableChange" -->
    <a-table
      :columns="columns"
      :data-source="dataSource"
      bordered
      size="middle"
      :row-class-name="
        (_record: any, index: number) =>
          index % 2 === 1 ? 'table-striped' : null
      "
      :scroll="{ x: 3000, y: 550 }"
      style="margin-top: 20px"
    >
    </a-table>
  </div>
</template>

<script setup lang="ts">
import { reactive, toRaw, ref, computed, h, watch } from 'vue';
import { getDerateApprovaldById } from '#/api/core/planAudit';
import { message } from 'ant-design-vue';
const props = defineProps({
  detailData1: {
    type: Object,
    default: () => {},
  },
  detailType1: {
    type: Number,
    default: () => 0,
  },
});
const datas = ref();
const types = ref();

const columns = [
  {
    title: '减免日期',
    dataIndex: 'derateTime',
    key: 'derateTime',
    width: 100,
    align: 'center',
  },
  {
    title: '减免方式',
    dataIndex: 'derateWay',
    key: 'derateWay',
    width: 80,
    align: 'center',
  },
  {
    title: '违约金减免类型',
    dataIndex: 'derateType',
    key: 'derateType',
    width: 80,
    align: 'center',
  },
  // {
  //   title: '折扣率',
  //   dataIndex: 'index',
  //   key: 'index',
  //   width: 80,
  //   align: 'center',
  // },
  {
    title: '减免金额',
    dataIndex: 'derateMoney',
    key: 'derateMoney',
    width: 80,
    align: 'center',
  },
  {
    title: '减免原因',
    dataIndex: 'derateReason',
    key: 'derateReason',
    width: 80,
    align: 'center',
  },
  {
    title: '操作人',
    dataIndex: 'operator',
    key: 'operator',
    width: 80,
    align: 'center',
  },
  {
    title: '操作时间',
    dataIndex: 'operatorTime',
    key: 'operatorTime',
    width: 80,
    align: 'center',
  },
  // {
  //   title: '审批状态',
  //   dataIndex: 'index',
  //   key: 'index',
  //   width: 80,
  //   align: 'center',
  // },
];
const dataSource = ref([]);
// 获取表格数据
const getTableData = async () => {
  //   type (0:应收 ,1:违约金)
  dataSource.value = [];
  const res = await getDerateApprovaldById(datas.value.id, types.value);
  if (res) {
    dataSource.value.push(res);
  } else {
    message.error('暂无数据');
  }
};

watch(
  () => [props.detailData1, props.detailType1],
  ([newVal1, newVal2]) => {
    console.log(newVal1, newVal2);
    datas.value = newVal1;
    types.value = newVal2;
    getTableData();
  },
  { immediate: true, deep: true },
);
</script>

<style scoped></style>
